<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('info'); 
	$cid = isset($cid) ? $cid : '';
$checkPagenum = isset($checkPagenum) ? $checkPagenum : $cfg_pagenum; 
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>单页信息管理</title>
<link href="templates/css/style.css" rel="stylesheet" type="text/css" />
<link href="templates/css/pagination.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/layindex.js"></script>
<script type="text/javascript" src="templates/js/forms.func.js"></script>

<script type="text/javascript">
function checkPagenum(id)
{	
var pn = document.getElementById(id).value; 
 
 	if (window.location.search=='')
	{
		location.href = "info.php?checkPagenum="+pn;
	}
	else{
		var s=window.location.search;
		location.href ="info.php"+s+"&checkPagenum="+pn;
	}
 
};
</script>
</head>
<body class="mainbody">

<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <span>单页信息管理</span>
  <a href="javascript:location.reload();" class="reload">刷新</a>
</div>
<!--/导航栏-->
<div id="floatHead" class="toolbar-wrap">
</div>
<form method="post" action="" id="form">
<!--列表-->
<div class="table-container">

  <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>

		<th width="5%">ID</th>
		<th width="40%">单页名称</th>
	
		<th width="45%">更新时间</th>

		<th width="15%" >操作</th>
    </tr>
  
  	<?php
	//权限验证
	if($cfg_adminlevel != 1)
	{
		//初始化参数
		$catgoryListPriv   = array();
		$catgoryUpdatePriv = array();

		$dosql->Execute("SELECT * FROM `#@__adminprivacy` WHERE `groupid`=".$cfg_adminlevel." AND `model`='category' AND `action`<>'add' AND `action`<>'del'");
		while($row = $dosql->GetArray())
		{
			//查看权限
			if($row['action'] == 'list')
				$catgoryListPriv[]   = $row['classid'];
			
			//修改权限
			if($row['action'] == 'update')
				$catgoryUpdatePriv[] = $row['classid'];
		}
	}


	//循环单页

	$sql ="SELECT * FROM `#@__infoclass` WHERE `siteid`='$cfg_siteid' AND `infotype`= 0 ";
	if(!empty($cid))  $sql .= " AND (`id`= $cid OR `parentstr` Like '%,$cid,%') ";
	$dopage->GetPage($sql,$checkPagenum,'DESC');
	while($row = $dosql->GetArray())
	{	
			//如果超级管理员直接显示
		if($cfg_adminlevel != 1)
		{
			if(in_array($row['id'],$catgoryListPriv))
			{
	?>
	 <tr>
     	<td align="center"><?php echo $row['id']; ?></td>
		<td><?php echo $row['classname']; ?></td>
		<td align="center"><?php
		$r = $dosql->GetOne("SELECT `content`,`posttime` FROM `#@__info` WHERE `classid`=".$row['id']);
		if(isset($r['content']))
			echo GetDateTime($r['posttime']);
		else
			echo '暂无内容';
		?></td>
		<td align="center"><?php

		//是否有修改权限
		if(in_array($row['id'],$catgoryUpdatePriv))
			echo '[<a href="info_update.php?id='.$row['id'].'">修改</a>]';
		else
			echo '[修改]';
		?></td>
    </tr>
	<?php
			}
		}
		else
		{
	?>
	 <tr>
     	<td align="center"><?php echo $row['id']; ?></td>
		<td><?php echo $row['classname']; ?></td>
		<td align="center"><?php
		$r = $dosql->GetOne("SELECT `content`,`posttime` FROM `#@__info` WHERE `classid`=".$row['id']);
		if(isset($r['content']))
			echo GetDateTime($r['posttime']);
		else
			echo '暂无内容';
		?></td>
		<td align="center"><a href="info_update.php?id=<?php echo $row['id']; ?>">修改</a></td>
    </tr>
	<?php

	}
		}
	?>
 <?php

//判断无记录样式
if($dosql->GetTotalRow() == 0)
{
	echo '<tr><td align="center" colspan="4">暂无记录</td></tr>';
}
?>
  </table>

</div>
<!--/列表-->

<!--内容底部-->
<div class="line20"></div>
<div class="pagelist">
  <div class="l-btns">
    <span>显示</span><input name="txtPageNum" type="text" value="<?php echo $checkPagenum;?>"  onblur="checkPagenum(this.id)"  onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="txtPageNum" class="pagenum" onkeydown="return checkNumber(event);" /><span>条/页</span>
  </div>
  <?php echo $dopage->GetList($sql,$checkPagenum); ?>

</div>
<!--/内容底部-->
</form>
</body>
</html>
